package com.home.truc.code.components;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import com.home.Entity.NhomMon;

public class MyJlistItemNhomMon extends JLabel implements ListCellRenderer {

	private static final long serialVersionUID = 1L;
	private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);

	  public MyJlistItemNhomMon() {
	    setOpaque(true);
	    setIconTextGap(12);
	  }

	  public Component getListCellRendererComponent(JList list, Object value,
	      int index, boolean isSelected, boolean cellHasFocus) {
	    NhomMon entry = (NhomMon) value;
	    setText(entry.getTen());
	    setIcon(entry.getImageIcon());
	    setToolTipText(entry.getTen()+", click để xem danh sách món của nhóm này");
	    if (isSelected) {
	      setBackground(HIGHLIGHT_COLOR);
	      setForeground(Color.white);
	    } else {
	      setBackground(Color.white);
	      setForeground(Color.black);
	    }
	    return this;
	  }
	}
